Note: There are often multiple ways to answer each question.

Load the ggplot2 and fueleconomy packages, as well as the vehicles dataset.

  1. Make a scatterplot of hwy vs. cty.

  2. Convert the cyl column to a factor.

  3. Modify the plot from Qn 1 such that the color of the dot represents cyl value. Also, change the color scale to “YlOrRd”.

  4. There is a lot of overplotting in the plot above. Remove the color scale and modify the previous plot so that alpha = 0.1.

  5. Make a histogram of year.

  6. Make a histogram of year with just 5 bins.

  7. For each value of cyl, make a violin plot of hwy values.

  8. For each value of cyl, make a boxplot of hwy values.

  9. Make a barplot to show how many cars of each type of fuel there are in the dataset. (Hint: Use the geom_bar geom.)

  10. Add a coord_flip() layer to the previous plot to make a horizontal barplot.